<?php
/**
 * Miffos framework
 * ----------------------------------------------
 *
 * Copyright (c) 2008, 2009 Martin Sadový (http://sodae.cz)
 *
 * This source file is subject to the "Miffos license" that is bundled
 * with this package in the file license.txt.
 *
 * @copyright  Copyright (c) 2008, 2009 Martin Sadový
 * @license    license.txt
 * @link       http://miffos.sodae.cz
 * @package    miffos
 * @version    $Id$
 */

class ViewFilter{

    private $filter;

    public function __construct($nameFilter){
        $file = dirname(__FILE__).'/Filters/'.$nameFilter.'.php';
        if(file_exists($file)){
            require_once $file;
            $class = $nameFilter.'ViewFilter';
            $this->filter = new $class;
        }else{
            throw new ApplicationException('missing-view-filter:'.$nameFilter,6);
        }

    }

    public function render($data){
        return $this->filter->render($data);
    }

    public function getInstance(){
        return $this->filter->getInstance();
    }
}

/**
 * Interface for View filters
 */
interface IViewFilter{
    /*
     * Render view filter
     */
    public function render($data);
    /**
     * Return instance if exist
     */
    public function getInstance();
}

?>